<?php

namespace app\common\validate;

use think\Validate;

class Ibec extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require',
        'contacts' => 'require',
        'contacts_mobile'   => 'require|regex:1[3-9]\d{9}',
    ];
    /**
     * 提示消息
     */
    protected $message = [
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name', 'contacts', 'contacts_mobile'],
        'edit' => ['name', 'contacts', 'contacts_mobile'],
    ];
    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'name' => __('Name'),
            'contacts' => __('Contacts'),
            'contacts_mobile' => __('Contacts_mobile'),
        ];
        $this->message = array_merge($this->message, [
            'contacts_mobile.regex' => __('手机号码格式错误')
        ]);
        parent::__construct($rules, $message, $field);
    }
}
